import BaseMctApi from "@/framework/infra/base/BaseMctApi";
import Order from "@/domain/entity/Order";

class OrderApi extends BaseMctApi {
  constructor() {
    super('order')
  }

  submitDetail(id) {
    return this.get('submit-detail', {id})
  }

  list(params) {
    const orderTime = params.orderTime
    if (orderTime) {
      params.orderStartTime = orderTime[0]
      params.orderEndTime = orderTime[1]
      delete params.orderTime
    }
    return this.get('/list', params).then(data => {
      if (data.data) {
        data.data = data.data.map(el => new Order(el))
      }
      return data;
    })
  }
}

export const orderApi = new OrderApi()
